<?php
// change the following paths if necessary
if(!file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'protected/config/app_config.php')) {
    die('app_config.php does not exists, please run the installer.');
}

include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'protected/config/app_config.php';

$yii= dirname(__FILE__).'/framework/yii.php';

defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
$config = array();
$plugins = glob(dirname(__FILE__).'/protected/extensions/plugins/*', GLOB_ONLYDIR);
if($plugins) {
    foreach($plugins as $plugin) {
        if(file_exists($plugin . '/config.php')) {
            $plugin_config = include $plugin . '/config.php';
            if($plugin_config) {
                $config = CMap::mergeArray($config, $plugin_config);
            }
        }
    }
}

$config= CMap::mergeArray($config, include dirname(__FILE__).'/protected/config/main.php');
$custom_config = json_decode(file_get_contents(dirname(__FILE__).'/protected/config/custom.php'), true);
$custom_config = $custom_config ? $custom_config : array();
$config = CMap::mergeArray($config,$custom_config);

//print_r($config);exit;
Yii::createWebApplication($config)->run();
